package com.tjnu.losca.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.tjnu.losca.Vo.ResponseVO;
import com.tjnu.losca.pojo.Userinfo;
import com.tjnu.losca.service.IUserinfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author losca
 * @since 2022-02-13
 */
@RestController
@RequestMapping("/User")
public class UserinfoController {
    @Autowired
    private IUserinfoService userinfoService;

    @GetMapping("/getUsers")
    public ResponseVO<IPage> getUsers(@RequestParam(defaultValue = "1") int pageNum,
                                                @RequestParam(defaultValue = "8") int pageSize,
                                                @RequestParam(defaultValue = "") String search)  {
        return ResponseVO.success(userinfoService.list(pageNum, pageSize, search));
    }

    @PostMapping("/del")
    public ResponseVO<Boolean> del(String userid){
        System.out.println(userid);
        return ResponseVO.success(userinfoService.del(userid));
    }

    @PostMapping("/rec")
    public ResponseVO<Boolean> rec(String userid){
        System.out.println(userid);
        return ResponseVO.success(userinfoService.rec(userid));
    }
    @PostMapping("/mulDel")
    public ResponseVO<Boolean> mulDel(String[] ids){
        return ResponseVO.success(userinfoService.mulDel(ids));
    }

    @PostMapping("/update")
    public ResponseVO<Boolean> update(Userinfo userinfo){
        return ResponseVO.success(userinfoService.update(userinfo));
    }


}
